<?php
class person{
private $name;
    private $age;
    private $sex;

public function __construct($n,$a,$s)
{
    $this->name=$n;
    $this->age=$a;
    $this->sex=$s;

}

    public function say()
{
    echo '我的名字叫'.$this->name
        .',我的年龄是'.$this->age
        .',我的性别是'.$this->sex;
}
public function __set($name,$value)
{
    if($name=='age')
    {
        $this->age=(($value<0)?1:$value);
    }
    $this->name=$value;
}
}


$my=new person('林武',20,'男');

$my->say();
$my->age=-40;
$my->say();